import React from 'react';
import {withAuth} from '@/utils/auth';
import {PureComponent} from 'react';
import {connect, formatMessage} from 'umi';
import {Button} from 'antd';


@connect(({testing}) => ({
  ...testing,
}))
class AntdComponent extends PureComponent {
  onNameChange = () => {
    console.log('onNameChange');
    const {dispatch} = this.props;
    dispatch({
      type: 'testing/changeName',
      payload: {
        value: 'changedName123',
      },
    });
  };

  render() {
    const {testName} = this.props;

    return (
      <div>
        <h1>
          {formatMessage({
            id: 'testing.format-message',
          })}
        </h1>
        <div data-testid="testName">{testName || 1231231231321}</div>
        <br />
        <Button onClick={this.onNameChange}>Change</Button>
      </div>
    );
  }
}

export default withAuth({
  code: 'code',
  Component: AntdComponent,
});
